package com.sailfish.springbootdemo.dao.db7;

import com.sailfish.springbootdemo.common.DB7TableName;
import com.sailfish.springbootdemo.pojo.db7.Mpackage;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MpackageDao {
    @Select("<script>" +
            " select " +
            " * " +
            " from " + DB7TableName.M_PACKAGE +
            " where pkg_name = #{pkgName}" +
            "</script>"
    )
    List<Mpackage> getMpackageByPkgName(@Param("pkgName") String pkgName);

    @Insert("<script>" +
            "insert into " + DB7TableName.M_PACKAGE + " " +
            "( "+
            "GUID, " +
            "pkg_name, " +
            "pin_min_pitch, " +
            "assembly_type, " +
            "foot_num, " +
            "alt_symbol, " +
            "pastemask_thickness_min, " +
            "pastemask_thickness_max, " +
            "is_testpoint, " +
            "is_tht_reflow, " +
            "is_tp, " +
            "is_offcenter_tp, " +
            "is_mounting_hole, " +
            "is_size_not_fit, " +
            "is_grid_design, " +
            "is_twins_design, " +
            "is_special_design, " +
            "is_window_open, " +
            "is_small_air_gap, " +
            "contains_via, " +
            "is_dense_comp, " +
            "is_silk_close_pad, " +
            "is_tsmk_rwidth_small, " +
            "is_via_rwidth_small, " +
            "is_phole_offcenter, " +
            "is_id_point, " +
            "is_hsk, " +
            "is_db_thole_reflow, " +
            "is_ntppitch_less_5, " +
            "no_tp_under, " +
            "no_hole_under, " +
            "no_trace_under, " +
            "no_uncap_via_under, " +
            "no_text_under, " +
            "thvpad_required, " +
            "otherside_keepout, " +
            "pad_airgap_min, " +
            "body_length, " +
            "body_width, " +
            "pitch_o2c_x, " +
            "pitch_o2c_y, " +
            "comp_type_vpl, " +
            "creator, " +
            "create_time, " +
            "modifier, " +
            "modify_time, " +
            "deleted " +
            ")"+
            "values "+
            "(" +
            "#{entity.GUID}, " +
            "#{entity.pkg_name}, " +
            "#{entity.pin_min_pitch}, " +
            "#{entity.assembly_type}, " +
            "#{entity.foot_num}, " +
            "#{entity.alt_symbol}, " +
            "#{entity.pastemask_thickness_min}, " +
            "#{entity.pastemask_thickness_max}, " +
            "#{entity.is_testpoint}, " +
            "#{entity.is_tht_reflow}, " +
            "#{entity.is_tp}, " +
            "#{entity.is_offcenter_tp}, " +
            "#{entity.is_mounting_hole}, " +
            "#{entity.is_size_not_fit}, " +
            "#{entity.is_grid_design}, " +
            "#{entity.is_twins_design}, " +
            "#{entity.is_special_design}, " +
            "#{entity.is_window_open}, " +
            "#{entity.is_small_air_gap}, " +
            "#{entity.contains_via}, " +
            "#{entity.is_dense_comp}, " +
            "#{entity.is_silk_close_pad}, " +
            "#{entity.is_tsmk_rwidth_small}, " +
            "#{entity.is_via_rwidth_small}, " +
            "#{entity.is_phole_offcenter}, " +
            "#{entity.is_id_point}, " +
            "#{entity.is_hsk}, " +
            "#{entity.is_db_thole_reflow}, " +
            "#{entity.is_ntppitch_less_5}, " +
            "#{entity.no_tp_under}, " +
            "#{entity.no_hole_under}, " +
            "#{entity.no_trace_under}, " +
            "#{entity.no_uncap_via_under}, " +
            "#{entity.no_text_under}, " +
            "#{entity.thvpad_required}, " +
            "#{entity.otherside_keepout}, " +
            "#{entity.pad_airgap_min}, " +
            "#{entity.body_length}, " +
            "#{entity.body_width}, " +
            "#{entity.pitch_o2c_x}, " +
            "#{entity.pitch_o2c_y}, " +
            "#{entity.comp_type_vpl}, " +
            "#{entity.creator}, " +
            "#{entity.create_time}, " +
            "#{entity.modifier}, " +
            "#{entity.modify_time}, " +
            "#{entity.deleted} " +
            ")"+
            "</script>"
    )
    Integer insertMpackage(@Param("entity") Mpackage entity);

    @Update("<script>" +
            "update " + DB7TableName.M_PACKAGE + " " +
            "set " +
            " <if test='entity.pkg_name != null'>pkg_name = #{entity.pkg_name},</if>" +
            " <if test='entity.pin_min_pitch != null'>pin_min_pitch = #{entity.pin_min_pitch},</if>" +
            " <if test='entity.assembly_type != null'>assembly_type = #{entity.assembly_type},</if>" +
            " <if test='entity.foot_num != null'>foot_num = #{entity.foot_num},</if>" +
            " <if test='entity.alt_symbol != null'>alt_symbol = #{entity.alt_symbol},</if>" +
            " <if test='entity.pastemask_thickness_min != null'>pastemask_thickness_min = #{entity.pastemask_thickness_min},</if>" +
            " <if test='entity.pastemask_thickness_max != null'>pastemask_thickness_max = #{entity.pastemask_thickness_max},</if>" +
            " <if test='entity.is_testpoint != null'>is_testpoint = #{entity.is_testpoint},</if>" +
            " <if test='entity.is_tht_reflow != null'>is_tht_reflow = #{entity.is_tht_reflow},</if>" +
            " <if test='entity.is_tp != null'>is_tp = #{entity.is_tp},</if>" +
            " <if test='entity.is_offcenter_tp != null'>is_offcenter_tp = #{entity.is_offcenter_tp},</if>" +
            " <if test='entity.is_mounting_hole != null'>is_mounting_hole = #{entity.is_mounting_hole},</if>" +
            " <if test='entity.is_size_not_fit != null'>is_size_not_fit = #{entity.is_size_not_fit},</if>" +
            " <if test='entity.is_grid_design != null'>is_grid_design = #{entity.is_grid_design},</if>" +
            " <if test='entity.is_twins_design != null'>is_twins_design = #{entity.is_twins_design},</if>" +
            " <if test='entity.is_special_design != null'>is_special_design = #{entity.is_special_design},</if>" +
            " <if test='entity.is_window_open != null'>is_window_open = #{entity.is_window_open},</if>" +
            " <if test='entity.is_small_air_gap != null'>is_small_air_gap = #{entity.is_small_air_gap},</if>" +
            " <if test='entity.contains_via != null'>contains_via = #{entity.contains_via},</if>" +
            " <if test='entity.is_dense_comp != null'>is_dense_comp = #{entity.is_dense_comp},</if>" +
            " <if test='entity.is_silk_close_pad != null'>is_silk_close_pad = #{entity.is_silk_close_pad},</if>" +
            " <if test='entity.is_tsmk_rwidth_small != null'>is_tsmk_rwidth_small = #{entity.is_tsmk_rwidth_small},</if>" +
            " <if test='entity.is_via_rwidth_small != null'>is_via_rwidth_small = #{entity.is_via_rwidth_small},</if>" +
            " <if test='entity.is_phole_offcenter != null'>is_phole_offcenter = #{entity.is_phole_offcenter},</if>" +
            " <if test='entity.is_id_point != null'>is_id_point = #{entity.is_id_point},</if>" +
            " <if test='entity.is_hsk != null'>is_hsk = #{entity.is_hsk},</if>" +
            " <if test='entity.is_db_thole_reflow != null'>is_db_thole_reflow = #{entity.is_db_thole_reflow},</if>" +
            " <if test='entity.is_ntppitch_less_5 != null'>is_ntppitch_less_5 = #{entity.is_ntppitch_less_5},</if>" +
            " <if test='entity.no_tp_under != null'>no_tp_under = #{entity.no_tp_under},</if>" +
            " <if test='entity.no_hole_under != null'>no_hole_under = #{entity.no_hole_under},</if>" +
            " <if test='entity.no_trace_under != null'>no_trace_under = #{entity.no_trace_under},</if>" +
            " <if test='entity.no_uncap_via_under != null'>no_uncap_via_under = #{entity.no_uncap_via_under},</if>" +
            " <if test='entity.no_text_under != null'>no_text_under = #{entity.no_text_under},</if>" +
            " <if test='entity.thvpad_required != null'>thvpad_required = #{entity.thvpad_required},</if>" +
            " <if test='entity.otherside_keepout != null'>otherside_keepout = #{entity.otherside_keepout},</if>" +
            " <if test='entity.pad_airgap_min != null'>pad_airgap_min = #{entity.pad_airgap_min},</if>" +
            " <if test='entity.body_length != null'>body_length = #{entity.body_length},</if>" +
            " <if test='entity.body_width != null'>body_width = #{entity.body_width},</if>" +
            " <if test='entity.pitch_o2c_x != null'>pitch_o2c_x = #{entity.pitch_o2c_x},</if>" +
            " <if test='entity.pitch_o2c_y != null'>pitch_o2c_y = #{entity.pitch_o2c_y},</if>" +
            " <if test='entity.comp_type_vpl != null'>comp_type_vpl = #{entity.comp_type_vpl},</if>" +
            " <if test='entity.creator != null'>creator = #{entity.creator},</if>" +
            " <if test='entity.create_time != null'>create_time = #{entity.create_time},</if>" +
            " <if test='entity.modifier != null'>modifier = #{entity.modifier},</if>" +
            " <if test='entity.modify_time != null'>modify_time = #{entity.modify_time},</if>" +
            " <if test='entity.deleted != null'>deleted = #{entity.deleted},</if>" +
            " where GUID = #{entity.GUID}" +
            "</script>"
    )
    Integer updateMpackage(@Param("entity") Mpackage entity);

    @Delete("<script>" +
            "delete from " + DB7TableName.M_PACKAGE + " " +
            "where GUID = #{GUID}" +
            "</script>"
    )
    Integer deleteMpackage(@Param("GUID") String GUID);
}
